export default {
    data() {
        return {
            type: 1,
            page: 1,
            limit: 10,
            count: 0,
            tableData: [], // 表格数据
            name: '',
        }
    },

    /**
     * 进入页面加载
     */
    mounted: function () {
        var that = this;
        //在缓存中获取值
        that.user_name = sessionStorage.getItem("user_name");
        that.user_id = sessionStorage.getItem("user_id");
        that.token = sessionStorage.getItem("access-token");
        if ((!that.token) || (!that.user_id) || (!that.user_name)) {
            that.$router.push('/login');
        }
        that.getList();
    },

    /**
     * 方法
     */
    methods: {
        /**
         * 获取列表
         */
        getList: function () {
            var that = this;
            that.tableData = [];
            that.count = 0;
            //请求的数据
            var formData = {};
            formData.token = that.token;

            if (that.name) {
                formData.keys = that.name;
            }
            that.$http.post(that.adminApi.api_url + "/User/userlist", formData, {
                emulateJSON: true
            }).then(
                function (res) {
                    // 处理成功的结果
                    if (res.body.list) {
                        for (var i in res.body.list) {
                            that.tableData.push({
                                i: i,
                                id: res.body.list[i].goods_id,
                                avatar_url: res.body.list[i].avatar_url,
                                nickname: res.body.list[i].nickname,
                                mobile: res.body.list[i].mobile,
                                create_time: res.body.list[i].create_time,
                                total_pay: res.body.list[i].total_pay,
                                order_success_count: res.body.list[i].order_success_count,

                            });
                        }
                        that.count = res.body.count;
                    }
                });
        },

        /**
         * 筛选
         */
        searchList: function () {
            let that = this;
            that.getList();
        },


        /**
         * 下一页
         * @param currentPage
         */
        handleCurrentChange: function (currentPage) {
            var that = this;
            that.page = currentPage;
        },


    }
}